<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.springframework.org/schema/data/jaxb">
<head>
    <meta charset="UTF-8">
    <title>项目生成器</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>

    <!--Bootstrap-->
    <link th:href="@{/bootstrap/css/bootstrap.min.css}" rel="stylesheet" />
    <link th:href="@{/validate/bootstrapValidator.css}" rel="stylesheet" />

    <script th:src="@{/jquery.js}"></script>
    <script th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
    <script th:src="@{/validate/bootstrapValidator.min.js}"></script>
    <script th:src="@{/validate/zh_CN.js}"></script>

</head>
<body>

<div class="jumbotron text-center" style="margin-bottom:0">
    <h1>项目生成器</h1>
</div>

<div class="container" style="margin-top: 20px" >
    <div class="row">
        <form class="form-horizontal" role="form" id="save_form" >
            <div class="form-group">
                <label for="groupId" class="col-sm-2 control-label">gropId</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="groupId" name="groupId" placeholder="请输入gropId:com.sjd.cn" data-bv-notempty="true"/>
                </div>
            </div>
            <div class="form-group">
                <label for="artifact" class="col-sm-2 control-label">Artifact</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="artifact" name="artifact" placeholder="请输入Artifact:项目名称如sjd-service" data-bv-notempty="true"/>
                </div>
            </div>
            <div class="form-group">
                <label for="port" class="col-sm-2 control-label">服务端口</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="port"  name="port" placeholder="请输入服务端口号:如8080" data-bv-notempty="true"/>
                </div>
            </div>
            <div class="form-group">
                <label for="serverName" class="col-sm-2 control-label">docker服务名</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="serverName" name="serverName" placeholder="请输入docker服务名：com.demo.cn" data-bv-notempty="true"/>
                </div>
            </div>

            <div class="form-group">
                <label for="dockerUrl" class="col-sm-2 control-label">docker私库url</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="dockerUrl" name="dockerUrl" placeholder="请输入docker私库url" data-bv-notempty="true"/>
                </div>
            </div>

            <div class="form-group">
                <label for="modelName" class="col-sm-2 control-label">模块名称</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="modelName" name="modelName" placeholder="请输入模块名称例如：sjd,jry" data-bv-notempty="true"/>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" class="btn btn-primary btn-lg btn-block" id="sub_btn" onclick="downLoad()">生成项目</button>
                </div>
            </div>

        </form>
    </div>
</div>
<script>
$(function () {

    $("#save_form").bootstrapValidator({
        message: '必须填写',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        live: 'disabled',
        fields: {
            groupId: {
                validators: {
                    notEmpty: {
                        message: '请输入gropId:com.sjd.cn:'
                    }
                }
            },
            artifact: {
                validators: {
                    notEmpty: {
                        message: '请输入Artifact:项目名称如sjd-service'
                    }
                }
            }
        }
    });
})


function  downLoad() {
    var bootstrapValidator = $("#save_form").data('bootstrapValidator');
    console.log(bootstrapValidator)
    //执行校验
    bootstrapValidator.validate();
    var  validate= bootstrapValidator.isValid();
    if (!validate) {//获取验证结果，如果成功，执行下面代码
        return;
    }

    window.location.href="createProject?groupId="+$("#groupId").val()+"&artifact="+$("#artifact").val()+"&port="+$("#port").val()+
        "&serverName="+$("#serverName").val()+"&dockerUrl="+$("#dockerUrl").val()+"&modelName="+$("#modelName").val();


}

</script>

</body>
</html>